import openpyxl
import requests

headers = {
    "content-type": "application/json",
    # 'Cookie': 'esso-authId=esso-1vghdf1j5a20f0e436e5ebd4df09f5d5ade0e6e6298',
    'Cookie': 'esso-authId=esso-29uvo1srmh624eacda29dfeb4ffc95d7cdd90ce50ed9',
    'User-Agent': 'Mozilla/5.0(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
                  'Chrome/84.0.4147.105 Safari/537.36 '
}


def ruin():
    workbook = openpyxl.load_workbook('C:/Users/九分石人/Documents/华翔语音坐席.xlsx')
    sheets = workbook.worksheets[0]
    rows = sheets.rows
    return rows


if __name__ == '__main__':
    rows = ruin()
    count = 0
    for row in rows:
        if count <= 0:
            count = count + 1
            continue
        payload = "{\"id\":\"" + str(row[0].value) + "\",\"newVoiceSeatPhone\":\"" + str(row[1].value) + "\"}"
        print(payload)
        # post = requests.post(url='https://admin.ruanfawu.com/api/virtualCall/bindVirtualUpdateSeat', data=payload,
        #                      headers=headers)
        # dump = json.dump(payload)
        # post = requests.post(url='https://ruin.wdai.com/api/virtualCall/bindVirtualUpdateSeat', json=dump,
        #                      headers=headers)
        post = requests.post(url='https://ruin.wdai.com/api/virtualCall/bindVirtualUpdateSeat', data=payload,
                             headers=headers)
        print(post.content.decode('utf-8'))
        count = count + 1
